/**
 *******************************************************************************
 * @file  s29gl064n90tfi03.h
 * @brief This file contains all the functions prototypes of the NOR Flash 
 *        component library for s29gl064n90tfi03.
 @verbatim
   Change Logs:
   Date             Author          Notes
   2020-06-12       Hongjh          First version
   2020-08-25       Hongjh          Typo
 @endverbatim
 *******************************************************************************
 * Copyright (C) 2020, Huada Semiconductor Co., Ltd. All rights reserved.
 *
 * This software component is licensed by HDSC under BSD 3-Clause license
 * (the "License"); You may not use this file except in compliance with the
 * License. You may obtain a copy of the License at:
 *                    opensource.org/licenses/BSD-3-Clause
 *
 *******************************************************************************
 */
#ifndef __S29GL064N90TFI03_H__
#define __S29GL064N90TFI03_H__

/* C binding of definitions if building with C++ compiler */
#ifdef __cplusplus
extern "C"
{
#endif

/*******************************************************************************
 * Include files
 ******************************************************************************/
#include "hc32_common.h"
#include "ddl_config.h"

/**
 * @addtogroup BSP
 * @{
 */

/**
 * @addtogroup Components
 * @{
 */

/**
 * @addtogroup S29GL064N90TFI03
 * @{
 */

#if (BSP_S29GL064N90TFI03_ENABLE == DDL_ON)

/*******************************************************************************
 * Global type definitions ('typedef')
 ******************************************************************************/

/*******************************************************************************
 * Global pre-processor symbols/macros ('#define')
 ******************************************************************************/
/**
 * @defgroup S29GL064N90TFI03_Global_Macros S29GL064N90TFI03 Global Macros
 * @{
 */

/**
 * @defgroup S29GL064N90TFI03_ID_Information S29GL064N90TFI03 ID Information
 * @{
 */
#define S29GL064N90TFI03_MANUFACTURER_ID    (0x0001U)
#define S29GL064N90TFI03_DEVICE_ID1         (0x227EU)
#define S29GL064N90TFI03_DEVICE_ID2         (0x2210U)
#define S29GL064N90TFI03_DEVICE_ID3         (0x2201U)
/**
 * @}
 */

/**
 * @}
 */

/*******************************************************************************
 * Global variable definitions ('extern')
 ******************************************************************************/

/*******************************************************************************
  Global function prototypes (definition in C source)
 ******************************************************************************/
/**
 * @addtogroup S29GL064N90TFI03_Global_Functions S29GL064N90TFI03 Global Functions
 * @{
 */
en_result_t S29GL064_Init(void);
void S29GL064_GetMemInfo(uint32_t *pu32MemStartAddr,
                                        uint32_t *pu32SectorsNumber,
                                        uint32_t *pu32BytesPerSector,
                                        uint32_t *pu32BytesPerBufProgram);
void S29GL064_Reset(void);
en_result_t S29GL064_ReadId(uint16_t au16Id[], uint32_t u32Length);
en_result_t S29GL064_ReadCfiId(uint16_t au16Id[], uint32_t u32Length);
en_result_t S29GL064_EraseChip(void);
en_result_t S29GL064_EraseSector(uint32_t u32SectorAddress);
en_result_t S29GL064_Program(uint32_t u32ProgramAddress, uint16_t u16Data);
en_result_t S29GL064_ProgramBuffer(uint32_t u32ProgramAddress,
                                            uint16_t au16Data[],
                                            uint32_t u32NumHalfwords);
uint16_t S29GL064_Read(uint32_t u32ReadAddress);
en_result_t S29GL064_ReadBuffer(uint32_t u32ReadAddress,
                                    uint16_t au16DataBuf[],
                                    uint32_t u32NumHalfwords);

/* Implement the below functions for the specified BSP board */
en_result_t BSP_SMC_S29GL064_Init(void);
void BSP_SMC_S29GL064_GetMemInfo(uint32_t *pu32MemStartAddr,
                                        uint32_t *pu32SectorsNumber,
                                        uint32_t *pu32BytesPerSector,
                                        uint32_t *pu32BytesPerBufProgram);
en_result_t BSP_SMC_S29GL064_ReadId(uint32_t u32DevicBaseAddress,
                                        uint16_t au16Id[],
                                        uint32_t u32Length);
en_result_t BSP_SMC_S29GL064_ReadCfiId(uint32_t u32DevicBaseAddress,
                                            uint16_t au16Id[],
                                            uint32_t u32Length);
en_result_t BSP_SMC_S29GL064_GetStatus(uint32_t u32DevicBaseAddress,
                                            uint32_t Timeout);
void BSP_SMC_S29GL064_Reset(uint32_t u32DevicBaseAddress);
en_result_t BSP_SMC_S29GL064_EraseChip(uint32_t u32DevicBaseAddress);
void BSP_SMC_S29GL064_EraseSector(uint32_t u32DevicBaseAddress,
                                        uint32_t u32SectorAddress);
en_result_t BSP_SMC_S29GL064_Program(uint32_t u32DevicBaseAddress,
                                            uint32_t u32ProgramAddress,
                                            uint16_t u16Data);
uint16_t BSP_SMC_S29GL064_Read(uint32_t u32DevicBaseAddress,
                                    uint32_t u32ReadAddress);
en_result_t BSP_SMC_S29GL064_ProgramBuffer(uint32_t u32DevicBaseAddress,
                                                  uint32_t u32ProgramAddress,
                                                  const uint16_t au16Data[],
                                                  uint32_t u32NumHalfwords);
en_result_t BSP_SMC_S29GL064_ReadBuffer(uint32_t u32DevicBaseAddress,
                                            uint32_t u32ReadAddress,
                                            uint16_t au16DataBuf[],
                                            uint32_t u32NumHalfwords);

/**
 * @}
 */

#endif /* BSP_S29GL064N90TFI03_ENABLE */

/**
 * @}
 */

/**
 * @}
 */

/**
* @}
*/

#ifdef __cplusplus
}
#endif

#endif /* __S29GL064N90TFI03_H__ */

/*******************************************************************************
 * EOF (not truncated)
 ******************************************************************************/
